using System;
using UnityEngine;

public class Seat : MonoBehaviour
{
	public Vehicle VehicleRoot;

	public string SeatID = "S1";

	public string CharacterID = string.Empty;

	public string PassengerID = "none";

	public bool IsDriver;

	public bool Active;

	[NonSerialized]
	public CharacterDriver passenger;

	public PlayerViewType ForceView;

	public bool FixRotation;

	public float ViewDistance = 30f;

	private void Awake()
	{
		PassengerID = "none";
	}

	private void Start()
	{
		if (VehicleRoot == null && (bool)base.transform.root)
		{
			VehicleRoot = base.transform.root.GetComponent<Vehicle>();
		}
	}

	public void CleanSeat()
	{
		CharacterDriver[] componentsInChildren = base.transform.GetComponentsInChildren<CharacterDriver>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			if ((bool)componentsInChildren[i])
			{
				if (componentsInChildren[i].transform.parent != null)
				{
					componentsInChildren[i].NoVehicle();
				}
				componentsInChildren[i].transform.parent = null;
				componentsInChildren[i].DrivingSeat = null;
				componentsInChildren[i] = null;
			}
		}
		if ((bool)passenger)
		{
			passenger.NoVehicle();
			passenger = null;
		}
	}

	public void CheckSeat()
	{
		if (base.transform.childCount <= 0)
		{
			Active = false;
			passenger = null;
		}
	}

	private void OnDrawGizmos()
	{
	}
}
